package org.btik.light.mobile.ui.devs;

import android.view.SurfaceHolder;
import org.btik.context.SimpleContext;
import org.btik.light.mobile.meta.VideoChannelType;
import org.btik.video.server.VideoServer;

import static org.btik.light.mobile.platform.conf.ContextGlobalNames.VIDEO_SERVER;

/**
 * @author lustre
 * @since 2023/5/6 13:16
 */
public interface VideoCapability {

    default void bindChannel(SurfaceHolder holder , VideoChannelType videoChannelType){
        SurfaceHolder.Callback callback = SimpleContext.get(videoChannelType.getBeanId());
        for (VideoChannelType value : VideoChannelType.values()) {
            SurfaceHolder.Callback callback1 = SimpleContext.get(value.getBeanId());
            if(callback1 != null){
                holder.removeCallback(callback1);
            }
        }
        holder.addCallback(callback);
        VideoServer videoServer = SimpleContext.get(VIDEO_SERVER);
        videoServer.switchVideoChannel(videoChannelType);
    }

}
